/**
 * JUnit imports
 */
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

/**
 * ShipTest test class
 * 
 * @author Hyoun-young Park
 * @version 1.0
 */
public class ShipTest {
	
		/**
		 * Ship object
		 */
		private final Ship ship = new Ship();
		
		/**
		 * Planet object
		 */
		private final Planet brax = new Planet("Brax", 
				Numbers.TEN.getNumber(), 
				Numbers.TEN.getNumber());
		
		/**
		 * Random Planet object
		 */
		private final Planet random = new Planet("Random", 
				Numbers.TWENTY.getNumber(), 
				Numbers.TWENTY.getNumber());
		
		/**
		 * Check if the setCurrentPlanet function works correctly.
		 */
		@Test
		public void testCurrentPlanet(){
			ship.setCurrentPlanet(brax);
			assertEquals("Failed getting the current planet", 
					ship.getCurrentPlanet(), brax);
			ship.moveToPlanet(random);
			assertEquals("Failed getting the current planet", 
					ship.getCurrentPlanet(), random);
		}
		
		/**
		 * Tests if the cargo space functions correctly. 
		 */
		@Test
		public void testCargoSpace(){
			ship.setCargoSpace(Numbers.TEN.getNumber());
			assertEquals("Failed getting the cargo space", 
					ship.getCargoSpace(), Numbers.TEN.getNumber());
			assertTrue("Failed getting the available cargo space", 
					ship.isCargoSpaceAvailable(1));
			assertFalse("Failed getting the available cargo space", 
					ship.isCargoSpaceAvailable(Numbers.ELEVEN.getNumber()));
		}
		
		/**
		 * Tests if the money calculates correctly.
		 */
		@Test
		public void testMoney(){
			ship.setMoney(0);
			ship.addMoney(Numbers.HUNDRED.getNumber());
			assertEquals("Failed getting the money", ship.getMoney(), 
					Numbers.HUNDRED.getNumber());
			ship.subtractMoney(Numbers.TWENTY.getNumber());
			assertEquals("Failed getting the money", ship.getMoney(), 
					Numbers.EIGHTY.getNumber());
		}
		
		/**
		 * Tests if the fuel is added and lost correctly.
		 */
		@Test
		public void testFuel(){
			ship.setFuel(0);
			ship.addFuel(Numbers.HUNDRED.getNumber());
			assertEquals("Failed getting the fuel", 
					Math.round(ship.getFuel()), Numbers.HUNDRED.getNumber());
			ship.subtractFuel(Numbers.TWENTY.getNumber());
			assertEquals("Failed getting the fuel", 
					Math.round(ship.getFuel()), Numbers.EIGHTY.getNumber());
		}
		
		/**
		 * toString method for the ShipTest
		 * 
		 * @return String representation of the ShipTest
		 */
		@Override
		public String toString() {
			return super.toString();
		}
}
